const {get_xb} = require("./webmssdk.es5.js")
const express = require('express')

const app = express()
const port = 3000
queryStr = "device_platform=webapp&aid=6383&channel=channel_pc_web&sec_user_id=MS4wLjABAAAARLFTwj6HKXBEEbtmsjaFtGcUv_5OxKCeCOhcUQHJ0XU&max_cursor=1660469714000&locate_query=false&show_live_replay_strategy=1&count=10&publish_video_strategy_type=2&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=109.0.0.0&browser_online=true&engine_name=Blink&engine_version=109.0.0.0&os_name=Windows&os_version=10&cpu_core_num=8&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50"
const userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36";

const xb = get_xb(queryStr, userAgent);
// const xb = sign(queryStr, userAgent);
console.log(xb)

function getXBogus(query, userAgent){
    const xbogus = get_xb(query, userAgent);
    console.log(xbogus)
    return {'X-Bogus':xbogus};
}


app.get('/x-bogus', (req, res) => {
    const query = req.query['query']
    const userAgent = req.query['user-agent']
    if (!query || !userAgent){
        res.sendStatus(400)
        res.send({'error': "参数错误"})
    }

    // console.log(req.query);
    res.json(getXBogus(query,userAgent))
})

app.listen(port, () => {
  console.log(`Example app listening on port http://localhost:${port}/x-bogus/`)
})